package com.cedifie.lendapp.ui.user.adapter

import android.graphics.Color
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.cedifie.lendapp.R
import com.cedifie.lib_baseadapter.CEDRecyclerViewAdapter
import com.cedifie.lib_baseadapter.CEDViewHolderHelper
import org.json.JSONObject

/**
 * Cedifie
 * @Author wwdeng
 * @CreateTime: 2024/6/17 13:45
 * @Annotation：校验方式
 */
class CedUserCheckPhoneNumberTypeAdapter(recyclerView: RecyclerView?): CEDRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_user_check_phone_number_type) {

    override fun setItemChildListener(helper: CEDViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.tvCheckType)
    }

    override fun fillData(helper: CEDViewHolderHelper, position: Int, model: JSONObject) {
        val tvCheckType = helper.getTextView(R.id.tvCheckType)
        tvCheckType.text = model.optString("checkTypeTitle")
        when(model.optBoolean("isSelected",false)){
            true -> {
                tvCheckType.setTextColor(Color.parseColor("#FFFFFFFF"))
                tvCheckType.setBackgroundResource(R.drawable.btn_state_pressed)
            }
            else -> {
                tvCheckType.setTextColor(Color.parseColor("#FF6C6C6C"))
                tvCheckType.setBackgroundResource(R.drawable.ced_circle_fill_fff0f0f0)
            }
        }
    }
}